package com.yueka.pojo;


/**
 * 后端统一返回结果
 */
public class R<T> {

    public Integer code; //编码：1成功，0为失败
    public String message; //错误信息
    public T data; //数据

    public static <T> R<T> success() {
        R<T> r = new R<>();
        r.code = 200;
        r.message = "success";
        return r;
    }

    public static <T> R<T> success(T object) {
        R<T> r = new R<>();
        r.data = object;
        r.code = 200;
        r.message = "success";
        return r;
    }

    public static <T> R<T> error(String msg) {
        R<T> r = new R<>();
        r.message = msg;
        r.code = 500;
        return r;
    }

}
